<?php defined('SYSPATH') or die('No direct script access.');

class Controller_GradeHorariaFrontEnd extends Controller {
//        protected $consumer;
//
//	public $view;
        public function logged_in_area(){
            if(!Model_User::logged_in(Kohana::$config->load("grademagica")->webuser_role_name)) {
                $redirect = '';
//                die($this->request->uri());
//                die('!'.$this->request->uri().'!');
                if($this->request->uri()!='/' && $this->request->uri()!='cadastro'){
                    $redirect = '?redirect='.$this->request->uri();
                }
//                $this->request->redirect();
                $this->request->redirect($this->language."cadastro".$redirect);
            }
        }
	public function before(){
            parent::before(); //<=NOTHING BY DEFAULT
	}
	public function  __construct(Request $request, Response $response) {
		parent::__construct($request, $response);
		$this->view = Smarty_View::factory('gm_base/html.tpl');
        
                $this->view->js = array(
                    "jquery-1.8.2.min"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/js/jquery-1.8.2.js",
                            ),
                    "jquery-ui"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/js/jquery-ui-1.9.1.custom.min.js",
                            ),
                    "grademagica_ui"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/grademagica/static/jscript/grademagica_ui.js",
                            ),
                    "general"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/grademagica/static/jscript/general.js",
                            ),
                );
                $this->view->css = array(
                    "jquery-ui"=> array(
                            "rel"=>"stylesheet",
                            "href"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/css/ui-lightness/jquery-ui-1.9.1.custom.min.css",
                            "type"=>"text/css",
                            "media"=>"screen",
                            "charset"=>"utf-8",
                    ),
                    "grademagica" => array(
                        "rel"=>"stylesheet",
                        "href"=>DOC_ROOT."modules/grademagica/static/css/grademagica.css",
                        "type"=>"text/css",
                        "media"=>"screen",
                        "charset"=>"utf-8",
                    ),
                    "blue" => array(
                        "rel"=>"stylesheet",
                        "href"=>DOC_ROOT."modules/grademagica/static/css/blue.css",
                        "type"=>"text/css",
                        "media"=>"screen",
                        "charset"=>"utf-8",
                    ),
                );
                $this->view->meta = array();
                $this->view->meta[] = array("http-equiv" => "Content-Type", "content" => "text/html;charset=UTF-8");
        
		$this->view->body = Smarty_View::factory('gm_base/body_frontend.tpl');
		if(isset(Kohana::$config->load('dec')->google_key) && !empty (Kohana::$config->load('dec')->google_key)) {
			$this->view->body->google_key = Kohana::$config->load('dec')->google_key;
		}

		$this->view->title = Kohana::$config->load('dec')->sys_name;
		$this->view->body->top = Smarty_View::factory('gm_base/top.tpl');
		$this->view->body->menu = Smarty_View::factory('gm_base/menu.tpl');
                $this->view->body->menu->selected = $this->request->uri();
		$this->view->body->content = "";
		$this->view->body->sidebar = "";
//		$this->view->body->footer = Arr::get(Kohana::modules(), "i18nUrl") ? (Views::Language(($redirect = substr(Request::current()->uri(),6))=="home/index"?'/':$redirect)) : "Default Footer";
		$this->view->body->footer = Smarty_View::factory("gm_base/footer.tpl");
//		if (Kohana::$profiling) {
//			$this->view->body->profile = View::factory('profiler/stats');
//			$this->view->css["profile"] = array(
//                            "rel" => "stylesheet",
//                            "href"=>DOC_ROOT."modules/dec/static/css/profile.css",
//                            "type" => "text/css",
//                            "media" => "screen",
//                            "charset" => "utf-8",
//                        );
//		}
	}
	
} // End Frontend